package com.zhangbo.share.baffle;

import com.alibaba.fastjson.JSONObject;
import com.zhangbo.share.api.IDataBaffleApi;
import com.zhangbo.share.bean.BaffleBean;
import com.zhangbo.share.bean.BaffleRule;
import com.zhangbo.share.bean.DataBaffleBean;
import com.zhangbo.share.dubbo.dto.ResultInfoDTO;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangbo on 2022/10/22.
 */
@Component
public class DataBaffleApiImpl implements IDataBaffleApi {

    @Override
    public DataBaffleBean dataBaffleResponse(String group, String code) {
        DataBaffleBean baffleBean = new DataBaffleBean();

        ResultInfoDTO resultInfoDTO = new ResultInfoDTO();
        resultInfoDTO.setResultCode("{resultCode}");
        resultInfoDTO.setResultMsg("{resultMsg}");
        baffleBean.setResult(JSONObject.toJSONString(resultInfoDTO));

        List<BaffleBean> baffleBeanList = new ArrayList<>();
        BaffleBean bean = new BaffleBean();
        bean.setType(DataBaffleEnums.BaffleTypeEnum.ID.getValue());
        bean.setParamName("resultCode");

        BaffleRule baffleRule = new BaffleRule();
        baffleRule.setIdLength(24);
        baffleRule.setIdPrefix("");
        bean.setBaffleRule(baffleRule);
        baffleBeanList.add(bean);

        bean = new BaffleBean();
        bean.setType(DataBaffleEnums.BaffleTypeEnum.DATE.getValue());
        bean.setParamName("resultMsg");

        baffleRule = new BaffleRule();
        baffleRule.setBaseDate("yyyy-MM-dd");
        bean.setBaffleRule(baffleRule);
        baffleBeanList.add(bean);

        baffleBean.setBaffleBean(baffleBeanList);

        return baffleBean;
    }
}
